package com.yzd.learnjava.containers;

import javax.management.RuntimeErrorException;

public class AssociativeArray <K,V>{
	
	private Object[][] pairs ;
	private int index ;
	public AssociativeArray(int length) {
		pairs = new Object[length][2];
	}
	
	public void put(K key, V value) {
		if(index > pairs.length) {
			throw new RuntimeException("");
		}
		
		pairs[index++] = new Object[] {key, value};
	}
	
	public V get(K key) {
		for(int i = 0 ; i < pairs.length; i++) {
			if(key.equals(pairs[i][0])) {
				return (V)pairs[i][1];
			}
		}
		
		return null;
	}

}
